package com.wjk.kylin.id.core.spring.boot.autoconfigure.kid;

import com.wjk.kylin.id.core.spring.boot.autoconfigure.KylinIdProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author wjk
 */
@Configuration
@ConditionalOnProperty(name = "kylin.id.kid.enable", havingValue = "true")
@EnableConfigurationProperties({KIdProperties.class,KylinIdProperties.class})
public class KIdAutoConfiguration {
    private static final Logger LOGGER = LoggerFactory.getLogger(KIdAutoConfiguration.class);

    @Autowired
    private KIdProperties properties;
    @Autowired
    private KylinIdProperties kylinIdProperties;

    @PostConstruct
    public void init() {
        //
        KylinIdInfoConfig.init(kylinIdProperties.getServer(), properties.getToken(), properties.getLoadIdThreshold());

        LOGGER.info(">>>>>>>>>>> kylin-kid init properties:{}", properties);
    }
}


